Loopless Generation of Multiset Permutations by Prefix Shifts
نویسنده
چکیده
This paper answers the following mathematical question: Can multiset permu-tations be ordered so that each permutation is a prefix shift of the previous permutation?Previously, the answer was known for the permutations of any set, and the permutationsof any multiset whose corresponding set contains only two elements. This paper also an-swers the following algorithmic question: Can multiset permutations be generated by aloopless algorithm that uses only a constant number of additional variables? Previously, thebest loopless algorithm used a linear number of additional variables. The answers to thesequestions are both yes.
منابع مشابه
Loopless generation of multiset permutations using a constant number of variables by prefix shifts
This paper answers the following mathematical question: Can multiset permutations be ordered so that each permutation is a prefix shift of the previous permutation? Previously, the answer was known for the permutations of any set, and the permutations of any multiset whose corresponding set contains only two elements. This paper also answers the following algorithmic question: Can multiset perm...
متن کاملGenerating Balanced Parentheses and Binary Trees by Prefix Shifts
We show that the set Bn of balanced parenthesis strings with n left and n right parentheses can be generated by prefix shifts. If b1, b2, . . . , b2n is a member of Bn, then the k-th prefix shift is the string b1, bk, b2, . . . , bk−1, bk+1, . . . , b2n. Prefix shift algorithms are also known for combinations, and permutations of a multiset; the combination algorithm appears in fascicles of Knu...
متن کاملCombinatorial Generation by Fusing Loopless Algorithms
Some combinatorial generation problems can be broken into subproblems for which loopless algorithms already exist. We discuss means by which loopless algorithms can be fused to produce a new loopless algorithm that solves the original problem. We demonstrate this method with two new loopless algorithms, MIXPAR and MULTPERM. MIXPAR generates well-formed parenthesis strings containing two differe...
متن کاملFusing Loopless Algorithms for Combinatorial Generation
Loopless algorithms are an interesting challenge in the field of combinatorial generation. These algorithms must generate each combinatorial object from its predecessor in no more than a constant number of instructions, thus achieving theoretically minimal time complexity. This constraint rules out powerful programming techniques such as iteration and recursion, which makes loopless algorithms ...
متن کاملGenerating Combinations by Prefix Shifts
We present a new Gray code for combinations that is practical and elegant. We represent combinations as bitstrings with s 0’s and t 1’s, and generate them with a remarkably simple rule: Identify the shortest prefix ending in 010 or 011 (or the entire bitstring if no such prefix exists) and then rotate (shift) it by one position to the right. Since the rotated portion of the string consists of a...
متن کامل